include(CMakeParseArguments)
find_package(Python3)
## Update resource files in Resources/ folder everytime when `Run/Debug` target.
function(c_sync_folder c_target src_dir dst_dir)
	set(luacompile_target COPY_RESOURCE-${c_target})
    if(NOT TARGET ${luacompile_target})
        add_custom_target(${luacompile_target} ALL
            COMMAND ${CMAKE_COMMAND} -E echo "Copying resource ..."
        )
        add_dependencies(${c_target} ${luacompile_target})
        set_target_properties(${luacompile_target} PROPERTIES
            FOLDER Utils
        )
    endif()
	add_custom_command(TARGET ${luacompile_target} POST_BUILD
		COMMAND ${Python3_EXECUTABLE} ARGS ${PRJ_ROOT_PATH}/cmake/scripts/sync_folder.py
			-s ${src_dir} -d ${dst_dir}
	)
endfunction()

function(c_get_resource_path output c_target)
    get_target_property(rt_output ${c_target} RUNTIME_OUTPUT_DIRECTORY)
    set(${output} "${rt_output}/${CMAKE_CFG_INTDIR}/Resources" PARENT_SCOPE)
endfunction()